<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/20
 * Time: 18:03
 */

namespace app\admin\controller;


use think\Controller;

class Upload extends Controller
{
    public function uploadOne(){
        $file=$this->request->file("file");
        $info=$file->rule("date")->move("./upload/",true,false);
        if($info){
            $savename=$info->getSaveName();
            $savename=str_replace("\\","/",$savename);
            return json([
                "code"      =>200,
                "msg"       =>"success",
                "url"      =>"/upload/".$savename
            ]);
        }else{
            return json([
                "errcode"       =>3000,
                "errmsg"        =>$info->getError()
            ]);
        }
    }
}